<?php

	namespace app\common\model\ohcard;

	use think\Model;
	use traits\model\SoftDelete;

	class Ohcard extends Model{
		use SoftDelete;

		protected $name = 'ohcard';

		// 自动写入时间戳字段
		protected $autoWriteTimestamp = 'integer';

		// 定义时间戳字段名
		protected $createTime = 'createtime';
		protected $updateTime = 'updatetime';
		protected $deleteTime = 'deletetime';

		public function getList($where = [], $order = 'number asc'){
			$model = $this->setWhere($where,$order);
			return $model->select();
		}

		public function setWhere($where, $order = 'number asc'){
			$model = $this->order($order);

			if(isset($where['type'])){
				if(is_array($where['type'])){
					$model = $model->where('type', 'in', $where['type']);
				}else{
					$model = $model->where('type', '=', $where['type']);
				}
			}
			if(isset($where['is_adult']) && $where['is_adult'] == 0) $model = $model->where('is_adult', '=', 0);
			if(isset($where['ids'])) $model = $model->whereIn('id',$where['ids']);

			return $model;
		}
	}